package com.ruoyi.web.controller.api;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.api.WCoinPrice;
import com.ruoyi.system.service.IWCoinPriceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 币种价格Controller
 * 
 * @author ruoyi
 * @date 2022-04-22
 */
@RestController
@RequestMapping("/api/wCoinPrice")
public class WCoinPriceController extends BaseController
{
    @Autowired
    private IWCoinPriceService wCoinPriceService;

    /**
     * 查询币种价格列表
     */
    @PreAuthorize("@ss.hasPermi('api:wCoinPrice:list')")
    @GetMapping("/list")
    public TableDataInfo list(WCoinPrice wCoinPrice)
    {
        startPage();
        List<WCoinPrice> list = wCoinPriceService.selectWCoinPriceList(wCoinPrice);
        return getDataTable(list);
    }

    /**
     * 导出币种价格列表
     */
    @PreAuthorize("@ss.hasPermi('api:wCoinPrice:export')")
    @Log(title = "币种价格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WCoinPrice wCoinPrice)
    {
        List<WCoinPrice> list = wCoinPriceService.selectWCoinPriceList(wCoinPrice);
        ExcelUtil<WCoinPrice> util = new ExcelUtil<WCoinPrice>(WCoinPrice.class);
        util.exportExcel(response, list, "币种价格数据");
    }

    /**
     * 获取币种价格详细信息
     */
    @PreAuthorize("@ss.hasPermi('api:wCoinPrice:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wCoinPriceService.selectWCoinPriceById(id));
    }

    /**
     * 新增币种价格
     */
    @PreAuthorize("@ss.hasPermi('api:wCoinPrice:add')")
    @Log(title = "币种价格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WCoinPrice wCoinPrice)
    {
        return toAjax(wCoinPriceService.insertWCoinPrice(wCoinPrice));
    }

    /**
     * 修改币种价格
     */
    @PreAuthorize("@ss.hasPermi('api:wCoinPrice:edit')")
    @Log(title = "币种价格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WCoinPrice wCoinPrice)
    {
        return toAjax(wCoinPriceService.updateWCoinPrice(wCoinPrice));
    }

    /**
     * 删除币种价格
     */
    @PreAuthorize("@ss.hasPermi('api:wCoinPrice:remove')")
    @Log(title = "币种价格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wCoinPriceService.deleteWCoinPriceByIds(ids));
    }
}
